<?php include '../../authorization_check.php' ?>
<?php include '../../checkSecretaryOnly.php' ?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">
<title>Enter instructor leave period</title>
<SCRIPT TYPE="text/javascript" src= "../../commonutils/util/util.js"> </SCRIPT>
</head>
<style type="text/css">
th {text-align: right}
</style>
<body>

<?php include 'top.html' ?>
<?php
  session_start();
  $programCode = $_SESSION['programCode'];
  $programShortName = $_SESSION['programShortName'];
  $semesterID = $_SESSION['semesterID'];
  $year = $_SESSION['year'];
  $semesterName = $_SESSION['semesterName'];
  
	echo " <p>You are currenttly working in <b> <font color=#00008B>".$year."-".$semesterName.
	     " </font></b> semester. </p>";
    echo " <hr color=blue>";	  
		 
?>


<FORM NAME ="form1" METHOD ="POST" ACTION = "EnterPeriod.php">

<?php
require_once '../../commonutils/db/DBConnectionManager.php';
$numerrors = 0;
if (isset($_POST['btnSubmit']))
{
	$instructorID = $_POST['instructorID'];
	
	$beginDate = $_POST['byyyy']."-".$_POST['bmm']."-".$_POST['bdd'];
	$endDate = $_POST['eyyyy']."-".$_POST['emm']."-".$_POST['edd'];
	
	if($endDate < $beginDate){
		$numerrors = $numerrors + 1;
		echo "<p><font color=red><b>* Leave end date must be later then begin date.</b></font></p>";
	}
	
	if($numerrors == 0)
	{
		$sqlquery = "insert into leaveperiod(semesterID, instructorID, beginDate, endDate) values"
					."(".$semesterID.", ".$instructorID.", '".$beginDate."', '".$endDate."')" ;
		// echo $sqlquery; 
		DBConnectionManager::query($sqlquery);
		//$row = mysql_fetch_assoc($result);
		echo "<p><font color=blue><b>You have successfully entered a leave period.</b></font></p>";
		echo "<p><a href=ViewLeavePeriods.php> View leave periods. </a></p>";
	}
}

?>

<table border=1 cellpadding=3>
<tr>
<td>
	<p>
		<table border=1 cellpadding="3">
		<tr>
		
		<th style="text-align:center">INSTRUCTOR </th>
		</tr>
		<?php
		require_once '../../commonutils/db/DBConnectionManager.php';
			$sqlquery = " select instructorID, concat(firstName, ' ', lastName) as iname from instructor ";
			$result = DBConnectionManager::query($sqlquery);
			while($row = mysql_fetch_assoc($result)){
				echo "<tr>";
				echo "<td><input type=radio name=instructorID  ";
				if(isset($_POST['btnSubmit']) && $row['instructorID'] == $_POST['instructorID'])
				   echo " checked ";
				echo " value=".$row['instructorID']."> ";
				echo " ".$row['iname']."</td>";
		
				echo "</tr>";		
			}	
		?>	
		</table>
	</p> 
</td>

<td valign=top>
	<p>
		<table border=1 valign=top>
		<tr>
		<th>Beginning date:</th>
		<td> 
		<select name="bdd" > 
			<option value="01">1</option>
			<option value="02">2</option>
			<option value="03">3</option>
			<option value="04">4</option>
			<option value="05">5</option>
			<option value="06">6</option>
			<option value="07">7</option>
			<option value="08">8</option>
			<option value="09">9</option>
			<option value="10">10</option>
			<option value="11">11</option>
			<option value="12">12</option>
			<option value="13">13</option>
			<option value="14">14</option>
			<option value="15">15</option>
			<option value="16">16</option>
			<option value="17">17</option>
			<option value="18">18</option>
			<option value="19">19</option>		
			<option value="20">20</option>
			<option value="21">21</option>
			<option value="22">22</option>
			<option value="23">23</option>
			<option value="24">24</option>
			<option value="25">25</option>
			<option value="26">26</option>
			<option value="27">27</option>
			<option value="28">28</option>
			<option value="29">29</option>
			<option value="30">30</option>
			<option value="31">31</option>						
		</select>
		 /
		<select name="bmm" > 
			<option value="01">January</option>
			<option value="02">February</option>
			<option value="03">March</option>
			<option value="04">April</option>
			<option value="05">May</option>
			<option value="06">June</option>
			<option value="07">July</option>
			<option value="08">August</option>
			<option value="09">September</option>
			<option value="10">October</option>
			<option value="11">November</option>
			<option value="12">December</option>
		</select>
		/
		<select name="byyyy" > 
			<option value="2008" <?php if($year == 2008) echo "selected"; ?> >2008</option>
			<option value="2009" <?php if($year == 2009) echo "selected"; ?> >2009</option>
			<option value="2010" <?php if($year == 2010) echo "selected"; ?> >2010</option>
			<option value="2011" <?php if($year == 2011) echo "selected"; ?> >2011</option>
			<option value="2012" <?php if($year == 2012) echo "selected"; ?> >2012</option>
			<option value="2013" <?php if($year == 2013) echo "selected"; ?> >2013</option>
			<option value="2014" <?php if($year == 2014) echo "selected"; ?> >2014</option>
			<option value="2015" <?php if($year == 2015) echo "selected"; ?> >2015</option>
		</select>
		
		</td>
		</tr>
		<tr>
		<th>End date:</th>
		<td> 
		<select name="edd" > 
			<option value="01">1</option>
			<option value="02">2</option>
			<option value="03">3</option>
			<option value="04">4</option>
			<option value="05">5</option>
			<option value="06">6</option>
			<option value="07">7</option>
			<option value="08">8</option>
			<option value="09">9</option>
			<option value="10">10</option>
			<option value="11">11</option>
			<option value="12">12</option>
			<option value="13">13</option>
			<option value="14">14</option>
			<option value="15">15</option>
			<option value="16">16</option>
			<option value="17">17</option>
			<option value="18">18</option>
			<option value="19">19</option>		
			<option value="20">20</option>
			<option value="21">21</option>
			<option value="22">22</option>
			<option value="23">23</option>
			<option value="24">24</option>
			<option value="25">25</option>
			<option value="26">26</option>
			<option value="27">27</option>
			<option value="28">28</option>
			<option value="29">29</option>
			<option value="30">30</option>
			<option value="31">31</option>						
		</select>
		 /
		<select name="emm" > 
			<option value="01">January</option>
			<option value="02">February</option>
			<option value="03">March</option>
			<option value="04">April</option>
			<option value="05">May</option>
			<option value="06">June</option>
			<option value="07">July</option>
			<option value="08">August</option>
			<option value="09">September</option>
			<option value="10">October</option>
			<option value="11">November</option>
			<option value="12">December</option>
		</select>
		/
		<select name="eyyyy" > 
			<option value="2008" <?php if($year == 2008) echo "selected"; ?> >2008</option>
			<option value="2009" <?php if($year == 2009) echo "selected"; ?> >2009</option>
			<option value="2010" <?php if($year == 2010) echo "selected"; ?> >2010</option>
			<option value="2011" <?php if($year == 2011) echo "selected"; ?> >2011</option>
			<option value="2012" <?php if($year == 2012) echo "selected"; ?> >2012</option>
			<option value="2013" <?php if($year == 2013) echo "selected"; ?> >2013</option>
			<option value="2014" <?php if($year == 2014) echo "selected"; ?> >2014</option>
			<option value="2015" <?php if($year == 2015) echo "selected"; ?> >2015</option>
		</select>
		
		</td>

		</tr>
		</table>
	</p>
	
	<p>
	  	<input type="submit" value="  Submit  " name="btnSubmit" onClick="return radioControl(instructorID)"> &nbsp;&nbsp;
		<input type="reset" value="  Reset  " name="btnReset"> &nbsp;&nbsp;
	</p>
</td>

</table>

<p>

</p>  
</FORM>
<?php include 'bottom.php' ?>

</body>


</html>